package com.sxyc.utils;

import com.jfinal.kit.PropKit;
import com.jfinal.plugin.redis.Cache;
import com.jfinal.plugin.redis.Redis;

public class RedisUtils {

	// 使用jFinal 日志
	private static com.jfinal.log.Log log = com.jfinal.log.Log.getLog(RedisUtils.class);

	public static Cache cache = Redis.use(PropKit.use("redis.properties").get("redisName"));

	public static String set(String key, Object value) {
		if (cache != null) {
			return cache.set(key, value);
		} else {
			return "";
		}
	}

	public static String setex(String key, int seconds, Object value) {
		if (cache != null) {
			return cache.setex(key, seconds, value);
		} else {
			return "";
		}
	}

	public static Object get(String key) {
		Object value = null;
		if (cache != null) {
			value = cache.get(key);
		}
		return value;
	}

}
